package com.yc.jpyy.mobile.controller;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.BizDao;
import com.yc.jpyy.mobile.service.BizService;

@Controller
@RequestMapping(value = "/student")
public class GetFeedbackListInfo extends BaseController{
	@Autowired
	private BizService bizService;
	//private static Logger logger = LoggerFactory.getLogger(GetFeedbackListInfo.class);	
	@Autowired
	private BizDao bizDao;
	
	/**
	 * 根据学员ID获取意见反馈列表
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/getFeedbackListInfo", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String getFeedbackListInfo(HttpServletRequest request)
			throws UnsupportedEncodingException {

		RestResponse response = new RestResponse();
		request.setCharacterEncoding("UTF-8");

		try {

			
			// 学员ID
			String stuId = request.getParameter("stuId");
			if(stuId!=null&&!stuId.isEmpty())
			{
				// 获取数据集合
				List<Map<String, Object>> map = bizDao.getFeedbackListInfo(Integer.parseInt(stuId));
	
				if (map != null && map.size() > 0) {
					 
					// 设置Json集合
					response.setData(map);
				} else {
					response.setErrorcode(1);
					response.setMessage("无意见反馈信息...");
				}
			}
			else
			{
				response.setErrorcode(1);
				response.setMessage("缺少必填字段！");
			}

		} catch (Exception e) {
			System.out.println("getFeedbackListInfo:"+ e.toString());
			// 异常信息
			response.setErrorcode(1);
			response.setMessage("意见反馈信息查询异常，请稍候重试！");
		} finally {
			return response.toJSON();
		}

	}
}
